package com.eleadin.ruleengine.enums;


public enum ErrorCode
{
    Success(0,"操作成功"),

    //系统错误部分
    SystemErrorBase( 0, "系统错误部分开始"),
    Failure(1,"操作失败"),
    NeedLogin(2,"用户没有登录"),
    UnExceptedError(3,"未知的错误发生"),
    IllegalArument(4,"参数错误"),
    SQLIntegrityConstraintViolation(5,"违反完整性约束"),
    NoAuthorization(6,"没有权限执行此操作"),
    CheckLoginFailure(7,"用户不存在或者密码错误"),
    UserNameExists(8,"登录名称已存在"),
    RoleNameExists(9,"角色名已存在"),
    RoleIsUsed(10,"角色已经被使用"),
    UserLocked(11,"用户被锁定"),
    OldPwdNotRight(12,"原密码不正确"),
    NewPwdNotMatchConfirmPwd(13,"新密码与确认密码不一致"),
    SqlSyntaxError(14,"数据库执行异常"),

    /**
     * 请求外部服务 1701 ~1800
     */
    RestTemplateErrorBase( 1700, "RestTemplate公用错误码开始"),
    RestTempleateNotParamInURL(RestTemplateErrorBase.code + 1, "请求外部服务未传入url"),
    RestTempleateConnecTimeout(RestTemplateErrorBase.code + 2, "请求外部服务超时"),
    RestTempleateConnectFailed(RestTemplateErrorBase.code + 3, "请求外部服务失败"),

    RestTempleateErrorCodeEnd(RestTemplateErrorBase.code + 100, "请求外部服务错误码结束"),
    /**----------------------------------------------------------------
     * 线以上内容请不要修改
     * ----------------------------------------------------------------**/
    // YourErrorCodeGoesHere(1000,"你的失败码请在后面定义"),

    ;

    private String desc;
    private int code;

    private ErrorCode(int code, String desc) {
        this.desc = desc;
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

    public boolean isSuccess() {
        return code == 0;
    }

    public boolean isFailed() {
        return code != 0;
    }
}
